package com.example.yls.demoa;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by yls on 2019/5/15.
 */

public class XfermodeView extends View {
    private Paint paint = new Paint();

    public XfermodeView(Context context) {
        super(context);
    }

    public XfermodeView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        //混合模式
        paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
        paint.setColor(Color.BLUE);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));


    }

    @Override
    protected void onDraw(Canvas canvas) {
//        paint.setStrokeWidth(2);
//        paint.setColor(Color.RED);
        canvas.drawColor(Color.GREEN);
        canvas.drawCircle(getWidth() / 2, getHeight() / 2, 200, paint);
        super.onDraw(canvas);
    }
}
